package com.honey.compilation.sql.ddl;

import com.honey.compilation.sql.SqlCommand;
import com.honey.compilation.sql.SqlKeyWord;
import com.honey.compilation.sql.SqlScript;
import com.honey.core.builder.CharacterBuilder;
import com.honey.core.builder.CharacterBuilderFactory;
import com.honey.core.compiler.CompilationException;
import com.honey.core.compiler.IndentSpace;

/**
 * 回滚命令 ROLLBACK .SQL 92定义如下:<br />
 * <rollback statement>    ::=   ROLLBACK [ WORK ]
 * @author Administrator
 *
 */
public class Rollback extends SQL92Comment implements SqlCommand ,SqlScript{
	
	private static final SqlKeyWord ROLLBACK_COMMAND=SqlKeyWord.ROLLBACK ;

	/*
	 * (non-Javadoc)
	 * @see com.honey.core.dom.sql.SqlCommand#getCommand()
	 */
	@Override
	public String getCommand() {
		
		return ROLLBACK_COMMAND.getValue();
	}

	/*
	 * (non-Javadoc)
	 * @see com.honey.core.dom.sql.ddl.SQL92Comment#compiledContent(int)
	 */
	@Override
	public CharacterBuilder compiledContent(int indentLevel ) throws CompilationException{
		CharacterBuilder answer = CharacterBuilderFactory.createC16StringBuilder();
		answer.append(super.compiledContent(indentLevel));
		IndentSpace.spaceIndent(answer, indentLevel);
		answer.append(ROLLBACK_COMMAND).append(SqlKeyWord.OPERATION_SEMICOLON);
		return answer;
	}
}
